//
//  CityCellOfNot_miss.m
//  FreeTravel
//
//  Created by 徐康 on 16/9/5.
//  Copyright © 2016年 KX. All rights reserved.
#import "WebViewOfCommendViewController.h"
#import "FreeTravelMacro.h"
#import "CellOfCityCellOfNot_miss.h"
#import "CityCellOfNot_miss.h"
#import "ModelOfNot_missCommendScenicSpotView.h"
#import "CityViewController.h"
@interface CityCellOfNot_miss ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@end
@implementation CityCellOfNot_miss
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createTableView];
    }
    return self;
}
- (void)createTableView{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
    [self addSubview:self.tableView];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.scrollEnabled = NO;
    [self.tableView registerClass:[CellOfCityCellOfNot_miss class] forCellReuseIdentifier:@"CellOfCityCellOfNot_miss"];
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 50)];
    label.text = @"不可错过";
    label.textAlignment = NSTextAlignmentCenter;
    label.font =  [UIFont fontWithName:@"Helvetica-Bold" size:15.f];
    self.tableView.tableHeaderView = label;
    
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    WebViewOfCommendViewController *vc = [[WebViewOfCommendViewController alloc]init];
    ModelOfNot_missCommendScenicSpotView *model = self.model.not_miss[indexPath.row];
    vc.url = model.link_url;
    CityViewController *city = (CityViewController *)self.nextResponder.nextResponder.nextResponder.nextResponder;
    [city.navigationController pushViewController:vc animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.model.not_miss.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CellOfCityCellOfNot_miss *cell = [tableView dequeueReusableCellWithIdentifier:@"CellOfCityCellOfNot_miss" forIndexPath:indexPath];
    cell.model = self.model.not_miss[indexPath.row];
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 200;
}
- (void)layoutSubviews{
    [super layoutSubviews];
    self.tableView.frame = self.contentView.bounds;
}
- (void)setModel:(ModelOfDataCommendScenicSpotView *)model{
    _model = model;
    [self.tableView reloadData];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
